
import storage from 'store';
// import { login } from '@/api/login';

const state = {
  token: undefined
};
const mutations = {
  SET_TOKEN: (state, token) => {
    state.token = token;
    storage.set('ACCESS_TOKEN', token);
  }
};
const actions = {
  Login ({ commit }, userInfo) {
    // return new Promise((resolve, reject) => {
    //   login(userInfo).then(response => {
    //     commit('SET_TOKEN', response.access_token);
    //     resolve(response);
    //   }).catch(error => {
    //     reject(error);
    //   });
    // });
    return new Promise((resolve, reject) => {
      commit('SET_TOKEN', 'this is temp token');
      resolve();
    });
  },
  Logout ({ commit, state }) {
    return new Promise((resolve) => {
      commit('SET_TOKEN', '');
      storage.remove('ACCESS_TOKEN');
      storage.clearAll();
      resolve();
    });
  }
};

export default {
  namespaced: true,
  state,
  mutations,
  actions
};
